#ifndef __WIZ_MEMORY_ALLOCATOR_HEAP_HPP__SHANHAOBO_19800429__
#define __WIZ_MEMORY_ALLOCATOR_HEAP_HPP__SHANHAOBO_19800429__

#include "../../../Base/WizBase.hpp"
#include "../../../DataType/WizDataType.hpp"

#include <windows.h>
#include <malloc.h>

namespace Wiz
{
    namespace Memory
    {
        namespace Allocator
        {
            namespace Heap
            {
                class Type
                {
                public:
                    static ::Wiz::Void::Ptr Allocate(
                        ::Wiz::Size::In SZ
                    )
                    {
                        return ::HeapAlloc(::GetProcessHeap(), 0, SZ);
                    }
                    static ::Wiz::Void::Ptr Allocate(
                        ::Wiz::Size::In SZ, 
                        ::Wiz::String::In FL,
                        ::Wiz::Int::In LN,
                        ::Wiz::String::In Func
                        )
                    {
                        return ::HeapAlloc(::GetProcessHeap(), 0, SZ);
                    }
                    static ::Wiz::Void::Type Deallocate(::Wiz::Void::InOutPtr MPtr)
                    {
                        ::HeapFree(::GetProcessHeap(), 0, MPtr);
                    }
                private:
                    // No instantiation
                    Type()
                    {}
                }; /// end of namespace Type

                template <int Alignment = 16>
                class AlignedType
                {
                public:
                    // compile-time check alignment is available.
                    WIZ_STATIC_ASSERT(Alignment > 0 && Alignment <= 128 && ((Alignment & (Alignment - 1)) == 0));
                    static ::Wiz::Void::Ptr Allocate(
                        ::Wiz::Size::In SZ
                        )
                    {
                        return ::HeapAlloc(::GetProcessHeap(), 0, SZ);
                    }
                    static ::Wiz::Void::Ptr Allocate(
                        ::Wiz::Size::In SZ, 
                        ::Wiz::String::In FL,
                        ::Wiz::Int::In LN,
                        ::Wiz::String::In Func
                        )
                    {
                        return ::HeapAlloc(::GetProcessHeap(), 0, SZ);
                    }
                    static ::Wiz::Void::Type Deallocate(::Wiz::Void::InOutPtr MPtr)
                    {
                        ::HeapFree(::GetProcessHeap(), 0, MPtr);
                    }
                private:
                    // No instantiation
                    AlignedType()
                    {}
                }; /// end of namespace AlignedType
            } /// end of namespace Heap
        } /// end of namespace Allocator
    } /// end of namespace Memory
} /// end of namespace Wiz

#endif /*__WIZ_MEMORY_ALLOCATOR_HEAP_HPP__SHANHAOBO_19800429__*/
